﻿Imports utilitiesLibrary

Public Class report
    Inherits System.Web.UI.Page
    Dim objDB As New DBConnect
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        objDB = Session("db")
    End Sub

    Protected Sub btnTopCust_Click(sender As Object, e As EventArgs) Handles btnTopCust.Click
        Dim sql As String
        Dim repDS As DataSet
        gvInvRep.Visible = False
        sql = "SELECT LoginID, CustName, TotalDollarSales FROM mall_customer ORDER BY TotalDollarSales DESC"
        repDS = objDB.getDataSet(sql)
        repDS.Tables(0).Columns(0).ColumnName = "Email Address"
        repDS.Tables(0).Columns(1).ColumnName = "Customer Name"
        repDS.Tables(0).Columns(2).ColumnName = "Total Sales"
        gvCustRep.DataSource = repDS
        gvCustRep.DataBind()
        gvCustRep.Visible = True


    End Sub

    Protected Sub btnInvList_Click(sender As Object, e As EventArgs) Handles btnInvList.Click
        Dim sql As String
        Dim qty As Integer
        Dim invDS As DataSet

        Try
            qty = CInt(txtInvQty.Text)
        Catch ex As Exception
            lblInfo.Text = "Only enter integers into textbox"
            lblInfo.ForeColor = Drawing.Color.Red
            lblInfo.Visible = True
            Exit Sub
        End Try

        gvCustRep.Visible = False
        sql = "SELECT d.DepartmentName, p.Description, p.Price, p.QuantityOnHand FROM mall_dept d INNER JOIN mall_product p ON p.DepartmentNumber=d.DepartmentNumber WHERE p.QuantityOnHand >= " & qty & " ORDER BY d.DepartmentName ASC, p.Price DESC"
        invDS = objDB.getDataSet(sql)
        invDS.Tables(0).Columns(0).ColumnName = "Department Name"
        invDS.Tables(0).Columns(1).ColumnName = "Product Desc."
        invDS.Tables(0).Columns(2).ColumnName = "Price"
        invDS.Tables(0).Columns(3).ColumnName = "QOH"
        gvInvRep.DataSource = invDS
        gvInvRep.DataBind()
        gvInvRep.Visible = True
    End Sub
End Class